<?php
use \tpfcore\Core;
?>
<!doctype html>
<head>
		<meta charset="utf-8">
		<!-- Set render engine for 360 browser -->
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!-- HTML5 shim for IE8 support of HTML5 elements -->
		<!--[if lt IE 9]>
			<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js">
			</script>
		<![endif]-->
		<link href="{$admin_assets_path}/css/theme.min.css" rel="stylesheet">
		<link href="{$admin_assets_path}/css/simplebootadmin.css" rel="stylesheet">
		<link href="{$admin_assets_path}/css/default.css" rel="stylesheet" />
		<link href="{$admin_assets_path}/css/font-awesome.min.css" rel="stylesheet" type="text/css">
		<style>
			.length_3{width: 180px;} form .input-order{margin-bottom: 0px;padding:3px;width:40px;}
			.table-actions{margin-top: 5px; margin-bottom: 5px;padding:0px;} .table-list{margin-bottom:
			0px;}
			.extends-params-wrap label{display: inline-block; margin: 0 10px;}
			.extends-params-wrap{display: none;}
		</style>
		<!--[if IE 7]>
			<link rel="stylesheet" href="{$admin_assets_path}/css/font-awesome-ie7.min.css">
		<![endif]-->
		<script type="text/javascript">
			//全局变量
			var GV = {
				WEB_ROOT:"",
				DIMAUB: "/",
				JS_ROOT: "/theme/backend/assets/js/",
				TOKEN: ""
			};
		</script>
		<!-- Le javascript==================================================-
		-> <!-- Placed at the end of the document so the pages load faster -->
		<script src="{$admin_assets_path}/js/jquery.js"></script>
		<script src="{$admin_assets_path}/js/wind.js"></script>
		<script src="{$admin_assets_path}/js/bootstrap.min.js"></script>
		<script src="{$admin_assets_path}/kindeditor/kindeditor-min.js"></script>
		<link href="{$admin_assets_path}/kindeditor/themes/default/default.css" rel="stylesheet"/>
	</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('cms/Fields/index',['form_id'=>$form_id])}">字段管理</a></li>
			{notempty name="list"}
			<li><a href="{:url('cms/Fields/add',['form_id'=>$form_id])}">添加字段</a></li>
			<li class="active"><a href="{:url('cms/Fields/edit',['id'=>$list[0]['id']])}">编辑字段</a></li>
			{else/}
			<li class="active"><a href="{:url('cms/Fields/add',['form_id'=>$form_id])}">添加字段</a></li>
			{/notempty}
			<li style="float: right;"><a href="{:url('cms/CustomForm/index')}">表单管理</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form" action="">
			<input type="hidden" name="id" value="{$form_id}">
			<fieldset>
				<div class="control-group">
					<label class="control-label">字段类型</label>
					<div class="controls">
						<select name="fields[type]" id="type">
							<option value="">选择字段类型</option>
							{volist name=":config('config.fields_type')" id="vo"}
							<option value="{$vo.key}">{$vo.name}</option>
							{/volist}
						</select>
						<span class="form-required">* 添加成功后不可修改</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">字段标题</label>
					<div class="controls">
						<input type="text" name="fields[title]">
						<span class="form-required">* 例如：用户姓名</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">字段名</label>
					<div class="controls">
						<input type="text" name="fields[name]">
						<span class="form-required">* 只能由英文字母、数字和下划线组成，并且仅能字母开头，添加后不能再次修改</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">字段提示信息</label>
					<div class="controls">
						<input type="text" name="fields[tips]">
						<span class="form-required">* 显示在字段下方或里面作为表单输入提示</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">数据验证正则</label>
					<div class="controls">
						<input type="text" name="fields[validate]" id="pattern">
						<select onchange="javascript:$('#pattern').val(this.value)" />
							<option value="">常用正则</option>
							<option value="/^[0-9.-]+$/">数字</option>
							<option value="/^[0-9-]+$/">整数</option>
							<option value="/^[a-z]+$/i">字母</option>
							<option value="/^[0-9a-z]+$/i">数字+字母</option>
							<option value="/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/">E-mail</option>
							<option value="/^[0-9]{5,20}$/">QQ</option>
							<option value="/^http:\/\//">超级链接</option>
							<option value="/^(1)[0-9]{10}$/">手机号码</option>
							<option value="/^[0-9-]{6,13}$/">电话号码</option>
							<option value="/^[0-9]{6}$/">邮政编码</option>
						</select>
						<span class="form-required">* 该字段将通过此正则进行数据验证，为空表示不验证</span>
					</div>
				</div>
				<div class="control-group extends-params-wrap">
					<div class="control-group">
					<label class="control-label">扩展参数设置</label>
					<div class="controls" style="border:1px #ddd dashed; padding: 20px 0;" id="params-list">
						
					</div>
				</div>
				</div>
			</fieldset>
			<div class="form-actions">
				<button class="btn btn-primary js-ajax-button" type="button">确定操作</button>
				<a class="btn" href="javascript:history.back(-1);">返回</a>
			</div>
		</form>
	</div>
	<script src="{$admin_assets_path}/js/common.js"></script>
	<script type="text/javascript">
	$("#type").change(function(){
		var val=$(this).val();
		if(val==""){
			$("#params-list").html("");
			$(".extends-params-wrap").hide();
			return false;
		}
		$.ajax({
			method:"post",
			url:"{:url('cms/Fields/get_extends_params')}",
			data:{"type":val},
			dataType:"html",
			success:function(data){
				if(data.length>0){
					$("#params-list").html(data);
					$(".extends-params-wrap").show();
				}else{
					$(".extends-params-wrap").hide();
				}
			}
		});
	});
	</script>
</body>
</html>